if(USE_SYSTEM_APTPKG)
   find_library(aptpkg NAMES apt-pkg NO_PACKAGE_ROOT_PATH REQUIRED)
   set(APTPKG_LIB "${aptpkg}")
   # it isn't easy to link against -private, but that is by design
   set(APTPRIVATE_LIB "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/libapt-private.so.0.0")
   set(APTPRIVATE_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}")
else()
   set(APTPKG_LIB "apt-pkg")
   set(APTPRIVATE_LIB "apt-private")
   set(APTPRIVATE_INCLUDE_DIRS "")
endif()

add_executable(mthdcat mthdcat.cc)
target_link_libraries(mthdcat ${APTPKG_LIB})
add_executable(testdeb testdeb.cc)
target_link_libraries(testdeb ${APTPKG_LIB})
add_executable(extract-control extract-control.cc)
target_link_libraries(extract-control ${APTPKG_LIB})
add_executable(aptwebserver aptwebserver.cc)
target_link_libraries(aptwebserver ${APTPKG_LIB} ${CMAKE_THREAD_LIBS_INIT})
add_executable(aptdropprivs aptdropprivs.cc)
target_link_libraries(aptdropprivs ${APTPKG_LIB})
add_executable(test_fileutl test_fileutl.cc)
target_link_libraries(test_fileutl ${APTPKG_LIB})
add_executable(createdeb-cve-2020-27350 createdeb-cve-2020-27350.cc)
add_executable(longest-dependency-chain longest-dependency-chain.cc)
target_link_libraries(longest-dependency-chain ${APTPKG_LIB} ${APTPRIVATE_LIB})
target_include_directories(longest-dependency-chain PRIVATE ${APTPRIVATE_INCLUDE_DIRS})

add_library(noprofile SHARED libnoprofile.c)
target_link_libraries(noprofile ${CMAKE_DL_LIBS})
